home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / C++ / Applications / NeuroSim 1.0 / .cp / CStdNeuralNet.cp < prev    next >
Text File  |  1996-02-19  |  2KB  |  53 lines

  1. // ===========================================================================
  2. //    CStdNeuralNet.cp            ©1996 Timo Eloranta
  3. // ===========================================================================
  4. //  A concrete neural net class derived from the abstract CNeuralNet class
  5.  
  6. #include "CStdNeuralNet.h"
  7. #include "CStdNeuron.h"
  8.  
  9. // ---------------------------------------------------------------------------
  10. //        • CStdNeuralNet
  11. //
  12. //          Called by:    CNeuroSimApp::InitNewNet
  13. // ---------------------------------------------------------------------------
  14. //    Constructor. Note that the constructor of the abstract base class 
  15. //    (CNeuralNet) must be called before creating and initializing the matrix.
  16.  
  17. CStdNeuralNet::CStdNeuralNet( 
  18.     const SGenParams &inParams )
  19.         : CNeuralNet( inParams.size )
  20. {
  21.     CreateMatrix();
  22.     InitMatrix( inParams );
  23. }
  24.  
  25. // ---------------------------------------------------------------------------
  26. //        • ~CStdNeuralNet
  27. // ---------------------------------------------------------------------------
  28. //    Destructor. Junk the matrix if it exists.
  29.  
  30. CStdNeuralNet::~CStdNeuralNet()
  31. {
  32.     if ( mMatrix ) {
  33.         delete [] mMatrix;
  34.         mMatrix = NULL;
  35.     }
  36. }
  37.  
  38. // ---------------------------------------------------------------------------
  39. //        • CreateMatrix
  40. //
  41. //          Called by:    CStdNeuralNet::CStdNeuralNet
  42. // ---------------------------------------------------------------------------
  43. //    Create the matrix as an array of neurons (of type CStdNeuron).
  44.  
  45. void
  46. CStdNeuralNet::CreateMatrix()
  47. {
  48.     if ( mMatrix )
  49.         delete [] mMatrix;
  50.  
  51.     mMatrix = new CStdNeuron[ mSize * mSize ];
  52. }
  53.